﻿using System;
using System.Collections.Generic;
using System.Text;

namespace WorkerTime.Utils
{
    class DurationFormatProvider : ICustomFormatter, IFormatProvider{
#region IFormatProvider Members

object  IFormatProvider.GetFormat(Type formatType)
{
        return this;
}

#endregion

#region ICustomFormatter Members

public string  Format(string format, object arg, IFormatProvider formatProvider)
{
    String formattedString;

    formattedString = (new TimeSpan((long) arg)).ToString();
    if (formattedString.LastIndexOf('.') > formattedString.LastIndexOf(':'))
        formattedString = formattedString.Substring(0, formattedString.LastIndexOf('.'));
    return formattedString;
}

#endregion
}
}
